<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>6_4_1-2-局部自定义指令</title>
</head>

<body>


  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  <div id="Application">
    <sub-com></sub-com>
  </div>
  <script>
    const App = Vue.createApp({});

    //子组件
    const sub = {
      directive: {
        //组件内部的自定义指令
        getfocus: {
          mounted(el) {
            el.focus();
          },
        },
      },
      mounted() {
        //组件挂载
        console.log(this.version);
      },
      template: `<input v-getfocus />`,
    };
    App.component("sub-com", sub);
    App.mount("#Application");
  </script>
</body>

</html>